package com.neulogistics.core.substation.api.application.rpc;

import cn.hutool.json.JSONObject;
import com.neulogistics.core.substation.api.application.rpc.dto.OrderDTO;
import com.neulogistics.core.substation.api.application.rpc.dto.WarehouseDTO;
import com.neulogistics.core.substation.domain.model.valueobject.CustomInfo;
import com.neulogistics.infrastructure.common.rpc.client.CustomerCenterClient;
import com.neulogistics.infrastructure.common.rpc.client.WarehouseClient;
import com.neulogistics.infrastructure.common.serviceresult.BaseResponse;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class SubstationRPC implements ISubstationRPC {
    @Resource
    CustomerCenterClient customerCenterClient;

    @Resource
    WarehouseClient warehouseClient;

    @Override
    public OrderDTO getOrderById(Long orderId) {
        OrderDTO orderDTO = customerCenterClient.getOrderById(orderId).getData().toBean(OrderDTO.class);

        return orderDTO;
    }

    @Override
    public CustomInfo getCustomerById(Integer customerId) {
        CustomInfo customInfo = customerCenterClient.getCustomerById(customerId).getData().toBean(CustomInfo.class);
        return customInfo;
    }

    @Override
    public WarehouseDTO getWarehouseById(Integer warehouseId) {
        WarehouseDTO warehouseDTO = warehouseClient.getWarehouseById(warehouseId).getData().toBean(WarehouseDTO.class);
        return warehouseDTO;
    }
}
